import request from '../../router/axios'

export function getTempByTableName(tableName, funcTypeId, orgId) {
  return request({
    url: '/admin/wfTemplate/bytablename',
    method: 'get',
    params: {
      tableName,
      funcTypeId,
      orgId
    }
  })
}

export function getTaskTodo(tableName, objectId) { // 根据表名和审批对象id获取待审批任务
  return request({
    url: '/admin/wfInstance/task/todo',
    method: 'get',
    params: {
      tableName,
      objectId,
    }
  })
}

export function getTaskHistory(params) { // 根据表名和审批对象id获取审批历史批注记录
  return request({
    url: '/admin/wfInstance/history',
    method: 'get',
    params
  })
}

export function getFieldById(params) { // 根据id获取详情
  return request({
    url: '/admin/field/info',
    method: 'get',
    params
  })
}

export function getTree(params) { // 获取树结构
  return request({
    url: '/admin/busiFunction/tree',
    method: 'get',
    params
  })
}

export function getUserByOrg(orgId) { // 通过组织ID查询全部用户
  return request({
    url: '/admin/user/list/all',
    method: 'get',
    params: {
      orgId
    }
  })
}

export function deptRoleList(param) {
  return request({
    url: '/admin/role/list',
    method: 'get',
    params: param
  })
}

export function getList(params) { // 根据查询条件获取职位list
  return request({
    url: '/admin/sysPosition/list',
    method: 'get',
    params
  })
}

export function getDeptList(params) { // 获取部门列表
  return request({
    url: '/admin/dept/list',
    method: 'get',
    params
  })
}

export function getFlowTask(objectId, tableName) { // 获取简易流程
  return request({
    url: '/admin/wfInstance/task/flow',
    method: 'get',
    params: {
      objectId,
      tableName
    }
  })
}

export function getFlowTaskPage(params) { // 获取流程过程分页
  return request({
    url: '/admin/wfInstance/task/opinion/history',
    method: 'get',
    params
  })
}

export function taskUrge(assigneeIds, objectId, tableName) { // 催促审核人处理任务
  return request({
    url: '/admin/wfInstance/task/urge',
    method: 'get',
    params: {
      assigneeIds,
      objectId,
      tableName
    }
  })
}

export function getCallBackUrl(tableName) { // 获取对象的审核回调接口
  return request({
    url: '/admin/sysconfig/audit/callback/urls',
    method: 'get',
    params: {
      tableName
    }
  })
}

export function cancelSubmit(router = '/admin', objectId, tableName) { // 取消审核
  return request({
    url: router + '/wf/instance/cancel/submit',
    method: 'post',
    params: {
      objectId,
      tableName
    }
  })
}

export function getWfRequireAudit(tableName, type) { // 判断该对象是否启用了流程审核
  return request({
    url: '/admin/wfInstance/requireaudit/check',
    method: 'post',
    params: {
      tableName,
      type
    }
  })
}

export function AddWfSubmit(router = '/admin', tableName, objectId) { // 提交审核，对象未启用流程审核时调用
  return request({
    url: router + '/wf/instance/submit',
    method: 'post',
    params: {
      tableName,
      objectId
    }
  })
}

export function getCurrentInstance(instanceId) { // 获取流程基本信息
  return request({
    url: '/admin/wfInstance/' + instanceId,
    method: 'get'
  })
}
